#include <iostream>
#include <functional> 

using namespace std;

int add (int x, int y){
    cout << "add(int, int)" << endl;
    return x + y;
}

int multiply(int x, int y, int z){
    cout << "multiply(int, int, int)" << endl;
    return x * y * z;
}

class Example{
public:
    int add (int x, int y){
        cout << "Example::add(int, int)" << endl;
        return x + y;
    }
};

void test(){
    int number = 10;
    auto f = bind(add, 1, 2);
    cout << "f() = " << f() << endl;

    auto f2 = bind(multiply, 3, 4, 5);
    cout << "f2() = " << f2() << endl;
    
    Example ex;
    auto f3 = bind(&Example::add, &ex, 3, 4);
    cout << "f3() = "<< f3() << endl; 

    auto f4 = bind(add, ref(number), placeholders::_1);
    number = 100;
    cout << "f4() = "<< f4(10) << endl; 
}


int main(){
    test();
    return 0;
}